#include "helper/sqlite/ExecutionResult.h"

#include <sqlite3.h>

#include "helper/sqlite/Error.h"
#include "helper/sqlite/IDB.h"

namespace helper {
namespace sqlite {


ExecutionResult::ExecutionResult(const std::error_code & ec, const IDB * db)
: ActionResult(ec)
, _db(db)
{
}
ExecutionResult::~ExecutionResult()
{
  _db = nullptr;
}

bool ExecutionResult::isOk() const {
  return ActionResult::isOk() && _db != nullptr;
}
int ExecutionResult::affectRows() const{
  if(_db != nullptr){
    return sqlite3_changes((sqlite3*)_db->raw_handler());
  }
  return -1;
}

}//namespace sqlite
}//namespace helper
